<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:c="http://java.sun.com/jsp/jstl/core">
	<f:view>
		<h:form id='form' method="POST" enctype="multipart/form-data">
			<h:head>
	<f:loadBundle basename="messages" var="msgs" />
	<title><h:outputText value="#{msgs.title}" /></title>
	
	<script type="text/javascript" src="../../resources/script/jquery.js"></script>
	
	<style type="text/css" title="currentStyle">
		@import "${facesContext.externalContext.requestContextPath}/views/management/css/item.css";
		@import "${facesContext.externalContext.requestContextPath}/views/css/theme.css";
	</style>
	<script type="text/javascript"
		src="${facesContext.externalContext.requestContextPath}/views/management/scripts/item.js"></script>
				
	<script type="text/javascript">
		$(document).ready(function () {
			var flag = $('[id="form:item_flag"]' );
			var flagLabel = $('[id="form:flag_label"]' );
				flag.click(function(){
					if(flag.is(':checked'))
					{
						flagLabel.text("Disabled");
					}
					else
					{
						flagLabel.text("Enabled");
					}
				});
		})
		
	</script>

		</h:head>
		<body>
			<ui:include src="../header/header.xhtml" />
			<br />
			<br />
			<br />

			<h3><h:outputText value="Edit Item #{itemBean.itemCode}" /></h3>

			<p></p>
			
			<div class="hidden_input">
				<h:inputText id="preview_icon" value="#{itemBean.previewIconPath}"></h:inputText>
				<h:inputText id="temp_icon" value="#{itemBean.tempIconFilePath}"></h:inputText>
				<h:inputText id="icon" value="#{itemBean.icon}"></h:inputText>
			</div>

			<div id="div" class="item_form">
				<table class="display" id="item_table">
					<tr>
						<td><h:outputLabel value="#{msg.item_code}" ></h:outputLabel></td>
						<td>
							<h:inputText id="item_code" value="#{itemBean.itemCode}" disabled="true">
							</h:inputText>
							<h:inputText id="item_code_hidden" value="#{itemBean.itemCode}" class="hidden_input">
							</h:inputText>
						</td>
						<td>
						</td>
					</tr>

					<tr>
						<td>
							<h:outputLabel value="#{msg.item_name }">
							</h:outputLabel>
						</td>
						<td>
							<h:inputText value="#{itemBean.itemName}" required="true">
							</h:inputText>
						</td>
						<td>
						</td>
					</tr>

					<tr>
						<td>
							<h:outputLabel value="#{msg.item_description}">
							</h:outputLabel>
						</td>
						<td>
							<h:inputText value="#{itemBean.itemDescription}">
								<f:validateLength minimum="1" maximum="300"></f:validateLength>
							</h:inputText>
						</td>
						<td></td>
					</tr>

					<tr>
						<td>
							<h:outputLabel value="Brand">
							</h:outputLabel>
						</td>
						<td>
							<h:inputText value="#{itemBean.brand}" disabled="true">
							</h:inputText>
							<h:inputText value="#{itemBean.brand}" class="hidden_input">
							</h:inputText>
						</td>
						<td>
							<h:commandButton id="brand_btn" value="Brand"
								action="#{itemBean.openBrandsAction}">
							</h:commandButton>
						</td>
					</tr>
					
					<tr>
						<td><h:outputLabel value="#{msg.item_price }"></h:outputLabel></td>
						<td><h:inputText value="#{itemBean.price}"></h:inputText></td>
						<td></td>
					</tr>


					<tr>
						<td>
							<h:outputLabel value="#{msg.item_orig_location}">
							</h:outputLabel>
						</td>
						<td>
							<h:inputText value="#{itemBean.origLocation}" disabled="true">
							</h:inputText>
							<h:inputText value="#{itemBean.origLocation}" class="hidden_input">
							</h:inputText>
						</td>
						<td>
							<h:commandButton id="location_btn" value="Location"
								action="#{itemBean.openLocationsAction}">
							</h:commandButton>
						</td>
					</tr>

					<tr>
						<td><h:outputLabel value="#{msg.item_category}"></h:outputLabel></td>
						<td>
							<h:inputText value="#{itemBean.category}" disabled="true"></h:inputText>
							<h:inputText value="#{itemBean.category}" class="hidden_input"></h:inputText>
						</td>
						<td>
						<h:commandButton id="category_btn" value="category"
							action="#{itemBean.openCategoriesAction}">
						</h:commandButton>
						</td>
					</tr>

					<tr>
						<td><h:outputLabel value="#{msg.item_icon}"></h:outputLabel></td>
						<td><h:graphicImage id="icon_image" value="#{itemBean.icon}"></h:graphicImage></td>
						<td>
							<h:inputFile id="icon_file" value="#{itemBean.iconFile}" onchange="loadBtnOnClick()">
								
							</h:inputFile>
							<h:commandButton id="load_icon_btn" value="Load" action="#{itemBean.loadIconAction}" onclick="return loadIcon()" class="hidden_input">
							</h:commandButton>
						</td>
					</tr>
					<tr>
						<td><h:outputLabel value="#{msg.item_attributes}"></h:outputLabel></td>
						<td><h:inputText value="#{itemBean.attribute}"></h:inputText></td>
						<td></td>
					</tr>

					<!-- 
					<tr>
						<td><h:outputLabel id="flag_label" value="#{msg.item_suspended }"></h:outputLabel>
						</td>
						<td><h:selectBooleanCheckbox id="item_flag"
								value="#{itemBean.suspended}">
							</h:selectBooleanCheckbox></td>
							<td></td>
					</tr>
					 -->
					<tr>
						<td><h:outputLabel value="#{msg.registered_time }"></h:outputLabel>
						</td>
						<td><h:outputLabel value="#{user.registeredTime}">
							</h:outputLabel></td>
							<td></td>
					</tr>

					<tr>
						<td><h:commandButton value="#{msg.submit}"
								action="#{itemBean.submitAction }" onclick="return loadIcon()">
							</h:commandButton></td>
						<td><h:commandLink value="#{msg.back_to_items}"
								action="#{itemBean.backToItemsAction }" /></td>
					</tr>

				</table>

			</div>

			<p></p>
			<ui:include src="../footer/footer.xhtml" />

		</body>
	</h:form>
</f:view>
</html>
